package com.tianji.learning.controller;


import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domain.dto.ReplyDTO;
import com.tianji.learning.domain.query.QuestionPageQuery;
import com.tianji.learning.domain.query.ReplyPageQuery;
import com.tianji.learning.domain.vo.ReplyVO;
import com.tianji.learning.service.IInteractionReplyService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 互动问题的回答或评论 前端控制器
 * </p>
 *
 * @author author
 * @since 2025-03-26
 */
@Slf4j
@RestController
@RequestMapping("/admin/replies")
@RequiredArgsConstructor
public class AdminInteractionReplyController {
    private final IInteractionReplyService interactionReplyService;

    /**
     * 按回答id返显回答
     */
    @GetMapping("/{id}")
    @ApiOperation("按id查询")
    public PageDTO<ReplyVO> pageQuery(ReplyPageQuery replyPageQuery) {
        return interactionReplyService.pageQuery(replyPageQuery);
    }

    /**
     * 添加回复
     * @param replyDTO
     */
    @ApiOperation("增加回复")
    @PostMapping
    public void addReply(@RequestBody ReplyDTO replyDTO) {
        interactionReplyService.addReply(replyDTO);
    }

    /**
     * 分页查询评论
     * @param replyPageQuery
     */
    @ApiOperation("分页查询")
    @GetMapping("/page")
    public PageDTO<ReplyVO> getPage(ReplyPageQuery replyPageQuery) {
        return interactionReplyService.getPage(replyPageQuery, false);
    }

    /**
     * 隐藏当前评论
     * @param id
     */
    @ApiOperation("设置隐藏")
    @PutMapping("/{id}/hidden/true")
    public void setHidden(@PathVariable Long id) {
        interactionReplyService.hideAll(id);
    }

    /**
     * 显示当前评论
     * @param id
     */
    @ApiOperation("设置显示")
    @PutMapping("/{id}/hidden/false")
    public void setDisplay(@PathVariable Long id) {
        interactionReplyService.displayAll(id);
    }



}

